package com.huawei.fastengine.fastview.showRpkDetail;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.huawei.fastengine.fastview.Config;
import com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils;
import o.eye;
import o.eye.d;

public class ShowRpkDetail {
    private static final String TAG = "ShowRpkDetail";
    private static volatile ShowRpkDetail showRpkDetail;
    private static final Object showRpkDetailLocker = new Object();
    private ServiceConnection conn = new ServiceConnection() {
        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            FastViewLogUtils.i(ShowRpkDetail.TAG, "ShowRpkDetail onServiceConnected");
            try {
                ShowRpkDetail.this.myBinder = d.ˎ(iBinder);
                ShowRpkDetail.this.myBinder.ˋ(ShowRpkDetail.this.getPackageName());
                ShowRpkDetail.this.unbindService(ShowRpkDetail.this.getContext());
            } catch (RemoteException e) {
                FastViewLogUtils.e(ShowRpkDetail.TAG, "showRpkDetail error");
            }
        }

        public void onServiceDisconnected(ComponentName componentName) {
            FastViewLogUtils.w(ShowRpkDetail.TAG, "ShowRpkDetail onServiceDisconnected");
        }
    };
    private Context context;
    private eye myBinder;
    private String packageName;

    private ShowRpkDetail() {
    }

    public static ShowRpkDetail getInstance() {
        if (showRpkDetail == null) {
            synchronized (showRpkDetailLocker) {
                if (showRpkDetail == null) {
                    showRpkDetail = new ShowRpkDetail();
                }
            }
        }
        return showRpkDetail;
    }

    public void bindService(Context context) {
        Intent intent = new Intent();
        intent.setAction("com.huawei.fastapp.engine.action.AIDL_SERVICE");
        intent.setPackage(Config.FASTAPP_PACKAGE_NAME);
        context.bindService(intent, this.conn, 1);
    }

    public Context getContext() {
        return this.context;
    }

    public String getPackageName() {
        return this.packageName;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public void setPackageName(String str) {
        this.packageName = str;
    }

    public void unbindService(Context context) {
        FastViewLogUtils.e(TAG, "ShowRpkDetail unbind Service");
        context.unbindService(this.conn);
    }
}
